package com.xueyi.operations.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;
import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum FaultProcessEnum {

    /**
     * 待受理
     */
    UNACCEPTED("unaccepted", "待受理"),
    /**
     * 处理中
     */
    PROCESSING("processing", "处理中"),
    /**
     * 待结束
     */
    UNCLOSED("unclosed", "待结束"),
    /**
     * 已完成
     */
    FINISHED("finished", "已完成");


    @EnumValue
    private final String code;

    @JsonValue
    private final String desc;


    @JsonCreator
    public static FaultProcessEnum convert(@JsonProperty("code") String code) {
        return Arrays.stream(FaultProcessEnum.values()).filter(e -> e.getCode().equals(code))
                .findFirst().orElse(null);
    }

}
